import React from 'react';

import { env } from '@/shared/constants';
import { rubik } from '@/shared/fonts';
import { generateMetaData } from '@/shared/lib';
import dayjs from 'dayjs';
import type { AppProps } from 'next/app';
import Head from 'next/head';
import Script from 'next/script';

import { metrika } from './config';
import { RootProvider } from './providers';

import 'dayjs/locale/ru';

dayjs.locale('ru');

export const App = ({ Component, pageProps }: AppProps) => (
  <>
    <Script async dangerouslySetInnerHTML={{ __html: metrika }} id="metrika"></Script>

    <Head>
      <meta
        content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"
        name="viewport"
      />

      {generateMetaData({ image: null, description: null })}
      <link crossOrigin="anonymous" href={env.apiUrl} rel="preconnect" />
      <meta content="app-id=1624893065" name="apple-itunes-app" />
    </Head>
    <style global jsx>{`
      html {
        font-family: ${rubik.style.fontFamily};
      }
    `}</style>
    <RootProvider {...pageProps}>
      <Component {...pageProps} />
    </RootProvider>
  </>
);
